#pragma once
#include <list>
#include <vector>
#include "../BondMarketStream.h"
namespace detail{

	class RealTimeDealCache{//命令缓存
		typedef MarketStreamInfo		Record;
		/*
		存储所有进入到CMarketStream::InsertCashData的参数xQBMarketStreamList_c的命令
		每一个xQBMarketStreamList_c* pLstdata对应一批转化后的MarketStreamInfo数组
		此MarketStreamInfo数组都属于一个id批次,id逐个递增
		*/
		class RecordBatch : public std::vector<Record>{
		public:
			int			m_batch;
		};
		typedef std::list<RecordBatch*>	RecordVecList;
	public:
		class Callback{
		public:
			virtual bool OnRecord(int id, const Record* record){ return true; }
		};
		int				m_id_start, m_id_end;
		int64_t			m_state_id;		// 
		int				m_capcity;
		RecordVecList	m_records;
	public:
		RealTimeDealCache(int64_t state);
		~RealTimeDealCache();
		void Add(int id, const Record* record);
		int64_t GetState()const{ return m_state_id; }
		int GetStartId()const{ return m_id_start; }
		int GetEndId()const{ return m_id_end; }
		bool GetSince(int id, Callback& callback);
	};


}
